/*
 * @Author: error: error: git config user.name & please set dead value or install git && error: git config user.email & please set dead value or install git & please set dead value or install git
 * @Date: 2023-11-16 22:29:03
 * @LastEditors: zhangguliu1234 984556209@.com
 * @LastEditTime: 2024-01-25 14:17:17
 * @FilePath: \sample_project\components\my_uart.h
 * @Description:
 *
 * Copyright (c) 2023 by ${git_name_email}, All Rights Reserved.
 */
#include <stdio.h>
// #include "my_wss.h"

#define N2O_Storage "N2O_Storage"

typedef struct
{
    time_t timestamp;
    char deviceType[20];
    char deviceId[14];
    char type[12];
    char once_time[13];
    char week_time[13];
    char date[12];
    char week[6];
} N2OSyncPolicy;

extern N2OSyncPolicy N2O_Sync;
extern char N2O_address;
extern int N2O_concentration;
extern int first_read_N2O;
extern int alarmMaxValue;
extern TaskHandle_t N2OSyncOnceHandle;
extern TaskHandle_t N2OSyncWeekHandle;
extern char N2OSyncOnce_flag; // 一次性策略定时任务创建标志位
extern char N2OSyncWeek_flag; // 周期性策略定时任务创建标志位
extern char N2Oalarm_flag;    // 浓度警报任务创建标志位
typedef struct CJsonStruct myCJson;
typedef struct changereport_parameters N2O_change_Task_Params;
typedef struct timedreport_parameters N2O_timed_Task_Params;
void myuart_init(void);
int sendData(const char *logName, const char *data);
void tx_task(void *arg);
void rx_task(void *arg);
void N2O_uart_init(void);
void N2O_send(const int port, const char *str, uint8_t length);
char N2O_set_address(char address);
void N2O_TEST(void);
int Read_N2O_concentration(void); // 1-成功，0-失败
void N2O_Change_task(N2O_change_Task_Params *params);
void N2O_Timed_task(N2O_timed_Task_Params *params);
void Publish_N2O_Change(N2O_change_Task_Params *params);
void Publish_N2O_concentration(esp_mqtt_client_handle_t *client);
int N2O_SyncPolicy_Save(myCJson *data);
void iterate_through_nvs(void);
void N2O_SyncPolicy_OneTime_Task(void *arg);
void N2O_SyncPolicy_OneTimeWeek_Task(void *arg);
int N2O_SyncPolicy_TaskKey(void);
void N2O_Alarm_Task(void *arg);
void Publish_N2O_Alarm(esp_mqtt_client_handle_t *client);
int N2O_Alarm_TaskKEY(void);
